/*
 * Fast car reverse image preview module
 *
 * Copyright (C) 2015-2018 AllwinnerTech, Inc.
 *
 * Contacts:
 * Zeng.Yajian <zengyajian@allwinnertech.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef __car_reverse_h__
#define __car_reverse_h__

#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/platform_device.h>

struct buffer_node {
	int size;
	int align;
	void *vir_address;
	void *phy_addrres;
};

struct buffer_manager {

	spinlock_t lock;

	/*
	 * three buffer:
	 * buffer[0] -- free buffer to be dequeue
	 * buffer[1] -- buffer to be display
	 * buffer[2] -- current display contants
	 */
	#define _FREE_BUFF		(0)
	#define _BACK_BUFF		(1)
	#define _SCREEN_BUFF	(2)
	struct buffer_node *buffer[3];

	struct buffer_node *(*dequeue_buffer)(struct buffer_manager *bm);
	void (*queue_buffer)(struct buffer_manager *bm, struct buffer_node *buff);

	struct buffer_node *(*acquire_buffer)(struct buffer_manager *bm);
	void (*release_buffer)(struct buffer_manager *bm, struct buffer_node *buff);
};

#endif
